package com.xqq.lottery.adapter;

import java.util.ArrayList;
import java.util.Map;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.xqq.lottery.FacePageFragment;
import com.xqq.lottery.OnOperationListener;
import com.xqq.lottery.view.PagerSlidingTabStrip.IconTabProvider;

public class FaceCategroyAdapter extends FragmentPagerAdapter implements
		IconTabProvider {
	
	private OnOperationListener onOperationListener;
	
	private Map<Integer, ArrayList<String>> data;

	public FaceCategroyAdapter(FragmentManager fm) {
		super(fm);
	}

	@Override
	public int getPageIconResId(int position) {
		return (Integer)data.keySet().toArray()[position];
	}

	@Override
	public Fragment getItem(int position) {
		FacePageFragment f=new FacePageFragment();
		f.setOnOperationListener(onOperationListener);
		Bundle b =new Bundle();
		b.putInt(FacePageFragment.ARG_POSITION, position);
		b.putStringArrayList(FacePageFragment.ARG_FACE_DATA, data.get(data.keySet().toArray()[position]));
		f.setArguments(b);
		return f;
	}

	@Override
	public int getCount() {
		return data == null? 0:data.size();
	}

	public Map<Integer, ArrayList<String>> getData() {
		return data;
	}

	public void setData(Map<Integer, ArrayList<String>> data) {
		this.data = data;
		notifyDataSetChanged();
	}
	
	public void setOnOperationListener(OnOperationListener listener){
		this.onOperationListener = listener;
	}
	
	

}
